<?php
/**
 *  NevuxBB - Free Forum Software
 *  Copyright (C) 2008, 2010 NevuxBB (No one specific author)
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Global File
 * File: global.php
 * Purpose: Including other files
 * Todo: Improve this file
 *
 */

// IIS isn't too good with this script because of it's error settings
$webserver = explode('/', $_SERVER['SERVER_SOFTWARE']);
if($webserver[0] == 'Microsoft-IIS') {
	error_reporting(E_ERROR);
}

// begin calculating execution time - only used for debugging
$pps_mtime = microtime();
$pps_mtime = explode(' ', $pps_mtime);
$pps_mtime = $pps_mtime[1] + $pps_mtime[0];
$pps_start = $pps_mtime; 
   
// for security measures
define('NEVUXBB_SET', true);

// is this being called from the ACP?
if($acp === true) {
	$new_dir = '../';
}

// from an upper level
if($up1l === true) {
	$new_dir = '../';
}

// this class is the system kernel, handles basic functions
// also the config needs loading
require($new_dir . 'system/classes/kernel_class.php');
require($new_dir . 'system/extra/config.php');

// is it aiming to look for files that actually exist?
if(!file_exists(BASE_PATH)) {
	trigger_error('Your settings have become misconfigured, please reconfigure them!', E_USER_ERROR);
}

// load the main classes
require(BASE_PATH . '/system/classes/db/Db_Abstraction.php');
require(BASE_PATH . '/system/classes/cache_class.php');
require(BASE_PATH . '/system/extra/settings.php');
require(BASE_PATH . '/system/classes/settings_class.php');
require(BASE_PATH . '/system/classes/core_class.php');
require(BASE_PATH . '/system/external/template/vlibTemplate.php');
require(BASE_PATH . '/system/classes/langcore_class.php');

// classes not needed for the ACP
if(!$acp) {
	require(BASE_PATH . '/system/classes/modrewrite_class.php');
	require(BASE_PATH . '/system/classes/url_class.php');
	require(BASE_PATH . '/system/classes/breadcrumb_class.php');
}

// start defining the main classes
$core_user_system     = new CoreUserSystem;
$core_base_system     = new BaseUserSystem;
$core_template_system = new vlibTemplate;
$core_lang_system     = new LanguageCore;

if(!$acp) {
	$core_nav_system  = new CoreBreadCrumb;
}

// load the actual header, in non-ACP mode
if(!$acp) {
	require(BASE_PATH . '/system/files/header.php');
} else {
	require(BASE_PATH . '/acp/files/header.php');
}

?>